#include <iostream>
#include <string>
#include <stack>
#include <algorithm>

using namespace std;

int main()
{
    string s;
    cin >> s;
    stack<char>st;
    for (auto& c : s)
    {
        if (c != ')')
            st.push(c);
        else
        {
            string t;
            while (st.top() != '(')
            {
                t += st.top();
                st.pop();
            }
            st.pop();
            reverse(t.begin(), t.end());
            cout << t << endl;
        }
    }
    return 0;
}
